﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using BeIT.MemCached;

/// <summary>
///StockMemcache 的摘要说明
/// </summary>
public class StockMemcache
{

    static string cacheName = "EMONEY_DATA";
    static StockMemcache()
    {
        string servers = System.Configuration.ConfigurationManager.AppSettings["StockMemcache"];
        if (!string.IsNullOrEmpty(servers))
        {
            MemcachedClient.Setup(cacheName, servers.Split('|'));
            MemcachedClient cache = MemcachedClient.GetInstance(cacheName);
            cache.SendReceiveTimeout = 5000;
            cache.ConnectTimeout = 5000;
            cache.MinPoolSize = 1;
            cache.MaxPoolSize = 5;
        }
    }

    public object GetClient()
    {
        return MemcachedClient.GetInstance(cacheName);
    }
    public  object Getstring(string key)
    {
        MemcachedClient cache = (MemcachedClient)GetClient();
        return cache.Get(key);
    }
    public T Get<T>(string key)
    {
        MemcachedClient cache = (MemcachedClient)GetClient();
        return (T)cache.Get(key);
    }
}